package com.evan.kdl.test.day01;

import com.evan.kdl.util.CommonUtils;

import java.util.concurrent.CompletableFuture;

/**
 * 开启一个不从任务中返回任何内容的CompletableFuture异步任务
 */
public class RunAsyncDemo {
    public static void main(String[] args) {
        CommonUtils.printThreadLog("main On");
        //底层还是开辟线程、异步任务线程
        CompletableFuture.runAsync(new Runnable() {
            @Override
            public void run() {
                CommonUtils.printThreadLog("读文件On");
                CommonUtils.sleepSecond(3);
                CommonUtils.printThreadLog("读文件Down");

            }
        });
        CommonUtils.printThreadLog("here are not blocked,main continue");
        CommonUtils.sleepSecond(4);
        CommonUtils.printThreadLog("main Down");
    }
}